/**
 * @author lulongwen
 * Date: 2023-09-03 10:37
 * Description:
 */

import { isNumber } from 'lodash-es';

// 节点默认尺寸
export const NODE_WIDTH = 80;

export const NODE_HEIGHT = 40;

// svg 绘制起始点，解决边不清晰的问题
export const NODE_PADDING = 1;

type IPath = [string, number, number, number, number]
// 创建节点路径
export const createPath = (paths: (string | number)[][], offsetX = 0, offsetY = 0) => {
  if (!paths.length) {
    return null
  }
  let path = ''
  // @ts-ignore
  paths.forEach((item: IPath) => {
    const [c, x, y, c2x, c2y] = item
    path += isNumber(y) ? ` ${c} ${x + offsetX} ${y + offsetY}` : ` ${c}`
    if (c2y) {
      path += ` ${c2x + offsetX} ${c2y + offsetY}`
    }
  })

  return path
}

